<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
/**
 * 用户模型
 */
class Notice_model extends CI_Model {
	public function __construct() {
		parent::__construct ();
	}
	
	/**
	 * 新增公告
	 */
	public function notice_insert($adminid) {
		$data = array (
				'picture' => $_POST ['picture'],
				'title' => $_POST ['title'],
				'content' => $_POST ['content'],
				'create_time' => time (),
				'create_uid' => $adminid 
		);
		
		$result = $this->db->insert ( 'pc_ddth_notice', $data );
		
		return $result;
	}
	
	/**
	 * 查询所有公告
	 */
	public function notice_list($id = FALSE) {
		if ($id === FALSE) {
			$query = $this->db->get ( 'pc_ddth_notice' );
			return $query->result_array ();
		}
		
		$query = $this->db->get_where ( 'pc_ddth_notice', array (
				'id' => $id 
		) );
		return $query->row_array ();
	}
	
	/**
	 * 查询3条公告
	 */
	public function notice_list3() {
		$query = $this->db->query ( "SELECT * FROM pc_ddth_notice order by id desc limit 0,3" );
		
		return $query->result_array ();
	}
}